# -*- coding: utf-8 -*-
# @Time : 2019/1/17 12:13
# @Author : Administrator
# @File : login_dec.py
# @Project : code
# @title : 登录和解密
from boss_GUI.tools.browser import Browser_Demo
import time
from selenium.webdriver.support.ui import Select

class LoDec():
    def __init__(self):
        self.driver = Browser_Demo().firefox()
        self.driver.get("http://192.168.2.141:8080/WoniuBoss2.5/")

    def login(self,username,pwd1):    #登录
        self.driver.find_element_by_name("userName").send_keys(username)
        self.driver.find_element_by_name("userPass").send_keys(pwd1)
        self.driver.find_element_by_xpath("//*[@id='form-login']/div/div/div[2]/button").click()
        return self.driver

    def dec(self,username,pwd1,pwd2):     #解密
        dr = self.login(username,pwd1)
        dr.find_element_by_id("btn-decrypt").click()
        dr.find_element_by_xpath("//*[@id='secondPass-modal']/div/div/div[2]/input").send_keys(pwd2)
        dr.find_element_by_xpath('//*[@id="secondPass-modal"]/div/div/div[3]/button').click()
        time.sleep(2)
        return dr
    def as2(self):
        Select(self.driver.find_element_by_xpath('/html/body/div[17]/div/div/form/div/div/div[7]/select')).select_by_visible_text("WNCDC034")

if __name__ == '__main__':
    LoDec().dec("wncd000","woniu123","woniu123")